package com.kmxd.ams.core.convert.impl;

import com.kmxd.ams.core.convert.AbstractDocConvert;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * pdf转换工具类
 *
 * @author ZuoLG
 */
@Service("shuke")
@Slf4j
public class OfdService implements AbstractDocConvert {

  private List<String> word = Arrays.asList("xls", "xlsx", "et", "xlsm");
  private List<String> excel = Arrays.asList("xls", "xlsx", "et", "xlsm");
  private List<String> ppt = Arrays.asList("ppt", "pptx");
  private List<String> pdf = Arrays.asList("pdf");
  private List<String> img =
      Arrays.asList("bmp", "jpg", "png", "tif", "gif", "svg", "webp", "apng");
  private List<String> html = Arrays.asList("html", "htm", "mht", "mhtml");
  private List<String> tiff = Arrays.asList("tif", "tiff");

  public static final String TYPE_UNSUPPORT = "不支持的格式";
  public static final String TYPE_WORD = "TYPE_WORD";
  public static final String TYPE_EXCEL = "TYPE_EXCEL";
  public static final String TYPE_PPT = "TYPE_PPT";
  public static final String TYPE_PDF = "TYPE_PDF";
  public static final String TYPE_IMG = "TYPE_IMG";
  public static final String TYPE_HTML = "TYPE_HTML";
  public static final String TYPE_TIFF = "TYPE_TIFF";

  /**
   * 设置指定的转换对象
   *
   * @param strs
   * @param fileType
   */
  @Override
  public void setFileType(List<String> strs, String fileType) {
    switch (fileType) {
      case TYPE_WORD:
        word = strs;
        break;
      case TYPE_EXCEL:
        excel = strs;
        break;
      case TYPE_PPT:
        ppt = strs;
        break;
      case TYPE_IMG:
        img = strs;
        break;
      case TYPE_PDF:
        pdf = strs;
        break;
      case TYPE_HTML:
        html = strs;
        break;
      case TYPE_TIFF:
        tiff = strs;
        break;
      default:
        break;
    }
  }

  /**
   * 获取 license
   *
   * @return
   */
  public boolean getLicense() {
    boolean flag = false;
    return flag;
  }

  /**
   * 文件转化pdf
   *
   * @param srcPath 需要转换的文件地址
   * @param pdfPath 转换后的pdf地址
   */
  @Override
  public void docConvert(String srcPath, String pdfPath) throws Exception {}

  @Override
  public int getFilePages(String srcPath) {
    return 0;
  }
}
